package com.yoso.thread;

import lombok.SneakyThrows;

/**
 * @author shizejin
 * @date 2021/12/31
 * @description:
 */
public class MyThread implements Runnable {
    public String name;

    public MyThread(String name) {
        this.name = name;
    }

    public MyThread() {
    }

    /**
     * When an object implementing interface <code>Runnable</code> is used
     * to create a thread, starting the thread causes the object's
     * <code>run</code> method to be called in that separately executing
     * thread.
     * <p>
     * The general contract of the method <code>run</code> is that it may
     * take any action whatsoever.
     *
     * @see Thread#run()
     */
    @SneakyThrows
    @Override
    public void run() {
        int i = 10;
        for (int i1 = 0; i1 < i; i1++) {
            Thread.sleep(500);
            System.out.println(Thread.currentThread().getName() + "---" + name);
        }
    }

}
